﻿Namespace CompoentModel

    Public Interface IChangedPropertyInf(Of Out T)

        Property PropertyName() As String
        ReadOnly Property OldValue() As T
        ReadOnly Property NewValue() As T

    End Interface

    Public Class ChangedPropertyInf(Of T)
        Implements IChangedPropertyInf(Of T)

        Private m_OldValue As T
        Private m_NewValue As T

        Public Property PropertyName() As String Implements IChangedPropertyInf(Of T).PropertyName

        Public ReadOnly Property OldValue() As T Implements IChangedPropertyInf(Of T).OldValue
            Get
                Return Me.m_OldValue
            End Get
        End Property

        Public ReadOnly Property NewValue() As T Implements IChangedPropertyInf(Of T).NewValue
            Get
                Return Me.m_NewValue
            End Get
        End Property

        Public Sub New(ByVal pName As String, Optional ByVal newValue As T = Nothing, Optional ByVal oldValue As T = Nothing)
            Me.PropertyName = pName
            Me.m_OldValue = oldValue
            Me.m_NewValue = newValue
        End Sub

        Public Function ConvertToBase() As IChangedPropertyInf(Of Object)
            Return New ChangedPropertyInf(Of Object)(Me.PropertyName, Me.NewValue, Me.OldValue)
        End Function

    End Class

End Namespace